package com.itheima.mString;

/*
    字符串操作
 */
public class Work06 {
    public static void main(String[] args) {
        //建立数组
        int[] arr = null;
        System.out.println(mothod(arr));
        int[] arr2 = {1, 2, 4, 5, 6, 7, 8, 9, 3};
        System.out.println(mothod(arr2));
    }

    public static String mothod(int[] arr) {
        String s = null;
        if (arr == null) {
            return null;
        } else if (arr.length == 0) {
            s = "[]";
            return s;
        } else {
            for (int i = 0; i < arr.length; i++) {
                if (i == 0) {
                    s = "[" + arr[0] + ",";
                } else if (i == arr.length - 1) {
                    s = s + arr[i] + "]";
                } else {
                    s = s + arr[i] + ",";
                }
            }
            return s;
        }
    }
}
